package android.app.gfestival;

import java.util.ArrayList;
import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;
import android.widget.TextView;

public class ProgramFistActivity extends Activity{
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.program_fist_screen);
		ListView listView = (ListView) findViewById(R.id.listview_pro_fist);
		List<String> list = new ArrayList<String>();
		for(int i = 0; i < 3; i++){
			list.add("The date " + i);
		}
		ProgramFistAdapter adapter = new ProgramFistAdapter(this, list);
		listView.setAdapter(adapter);
	}
	
	public class ProgramFistAdapter extends BaseAdapter{
		
		private List<String> list;
		private Context context;

		public ProgramFistAdapter(Context context, List<String> list){
			this.list = list;
			this.context = context;
		}
		@Override
		public int getCount() {
			// TODO Auto-generated method stub
			return list.size();
		}

		@Override
		public Object getItem(int position) {
			// TODO Auto-generated method stub
			return list.get(position);
		}

		@Override
		public long getItemId(int position) {
			// TODO Auto-generated method stub
			return position;
		}

		@Override
		public View getView(int position, View convertView, ViewGroup parentView) {
			// TODO Auto-generated method stub
			Holder holder = null;
			if(convertView == null){
				LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
				convertView = inflater.inflate(R.layout.program_fist_item, null);
				holder = new Holder();
				holder.textView = (TextView) convertView.findViewById(R.id.textview_pro_fist);
				convertView.setTag(holder);
			}else{
				holder = (Holder) convertView.getTag();
			}
			holder.textView.setText(list.get(position));
			return convertView;
		}
		
		private class Holder{
			TextView textView;
		}
		
	}

}
